package com.weimei.conversionTreasure.adapter;

import android.text.Editable;
import android.text.TextWatcher;
import android.widget.EditText;

import androidx.annotation.NonNull;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.weimei.conversionTreasure.R;


public class GDKgAdapter extends BaseQuickAdapter<GDKgAdapter.KgBean, BaseViewHolder> {
    public GDKgAdapter() {
        super(R.layout.item_kg);
    }

    @Override
    protected void convert(@NonNull BaseViewHolder holder, KgBean kgBean) {
        holder.setText(R.id.tv_jj,"基酒"+(getItemPosition(kgBean)+1));

        holder.setText(R.id.tv_tj,kgBean.getBaseAlcoholYVolume());
        holder.setText(R.id.edt_jiudu,kgBean.getDegree());
        holder.setText(R.id.edt_kg,kgBean.getQuality());
        holder.setText(R.id.edt_unit,kgBean.getPrice());

        kgBean.setDegree(((EditText)holder.getView(R.id.edt_jiudu)).getText().toString());
        kgBean.setQuality(((EditText)holder.getView(R.id.edt_kg)).getText().toString());
        kgBean.setPrice(((EditText)holder.getView(R.id.edt_unit)).getText().toString());

        ((EditText)holder.getView(R.id.edt_jiudu)).addTextChangedListener(new TextWatcher() {
            @Override
            public void beforeTextChanged(CharSequence s, int start, int count, int after) {
            }

            @Override
            public void onTextChanged(CharSequence s, int start, int before, int count) {

            }

            @Override
            public void afterTextChanged(Editable s) {
                kgBean.setDegree(s.toString());
            }
        });

        ((EditText)holder.getView(R.id.edt_kg)).addTextChangedListener(new TextWatcher() {
            @Override
            public void beforeTextChanged(CharSequence s, int start, int count, int after) {
            }

            @Override
            public void onTextChanged(CharSequence s, int start, int before, int count) {

            }

            @Override
            public void afterTextChanged(Editable s) {
                kgBean.setQuality(s.toString());
            }
        });

        ((EditText)holder.getView(R.id.edt_unit)).addTextChangedListener(new TextWatcher() {
            @Override
            public void beforeTextChanged(CharSequence s, int start, int count, int after) {
            }

            @Override
            public void onTextChanged(CharSequence s, int start, int before, int count) {

            }

            @Override
            public void afterTextChanged(Editable s) {
                kgBean.setPrice(s.toString());
            }
        });

    }


    public static class  KgBean{
        private String degree;
        private String quality;
        private String price;


        private String baseAlcoholYVolume;

        public String getBaseAlcoholYVolume() {
            return baseAlcoholYVolume;
        }

        public void setBaseAlcoholYVolume(String baseAlcoholYVolume) {
            this.baseAlcoholYVolume = baseAlcoholYVolume;
        }

        public String getDegree() {
            return degree;
        }

        public void setDegree(String degree) {
            this.degree = degree;
        }

        public String getQuality() {
            return quality;
        }

        public void setQuality(String quality) {
            this.quality = quality;
        }

        public String getPrice() {
            return price;
        }

        public void setPrice(String price) {
            this.price = price;
        }

        @Override
        public String toString() {
            return "KgBean{" +
                    "degree='" + degree + '\'' +
                    ", quality='" + quality + '\'' +
                    ", price='" + price + '\'' +
                    ", baseAlcoholYVolume='" + baseAlcoholYVolume + '\'' +
                    '}';
        }
    }
}
